package qc.module.platform.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import qc.module.platform.dto.division.AdminDivisionInfoDto;
import qc.module.platform.entity.QcAdminDivisions;

import java.util.List;

/**
 * AdminDivisionMapper
 *
 * @author QuCheng Tech
 * @create 2023/02/08
 */
@Mapper
public interface AdminDivisionMapper {
    AdminDivisionMapper MAPPER = Mappers.getMapper(AdminDivisionMapper.class);

    @Mapping(target = "level", source = "level.index")
    @Mapping(target = "lname", source = "level.value")
    AdminDivisionInfoDto toDto(QcAdminDivisions en);

    List<AdminDivisionInfoDto> toDtoList(List<QcAdminDivisions> list);

    ///**
    // * 该方法@AfterMapping注解可以将方法添加到上一方法的return语句前，@MappingTarget注解修饰的变量表示该变量被赋值过
    // *
    // * @param en  实体类
    // * @param dto 实体类dto
    // * @return qc.module.platform.dto.division.AdminDivisionInfoDto
    // * @author QcCheng Tech
    // * @since 2023/2/10
    // */
    //@AfterMapping
    //default AdminDivisionInfoDto toDivisionDto(QcAdminDivisions en, @MappingTarget AdminDivisionInfoDto dto) {
    //    //AdminDivisionInfoDto dto = new AdminDivisionInfoDto();
    //    for (DivisionLevelEnum levelEnum : DivisionLevelEnum.values()) {
    //        if (en.getLevel() == levelEnum.getIndex()) {
    //            dto.setLname(levelEnum.getValue());
    //        }
    //    }
    //    return dto;
    //}

}
